package com.ruoyi.aero.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.aero.domain.PlanInfo;
import com.ruoyi.aero.service.IPlanInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 计划信息Controller
 * 
 * @author swb
 * @date 2024-06-04
 */
@RestController
@RequestMapping("/aero/plan")
public class PlanInfoController extends BaseController
{
    @Autowired
    private IPlanInfoService planInfoService;

    /**
     * 查询计划信息列表
     */
    @PreAuthorize("@ss.hasPermi('aero:plan:list')")
    @GetMapping("/list")
    public TableDataInfo list(PlanInfo planInfo)
    {
        startPage();
        List<PlanInfo> list = planInfoService.selectPlanInfoList(planInfo);
        return getDataTable(list);
    }

    /**
     * 查询计划信息列表 不分页
     */
    @PreAuthorize("@ss.hasPermi('aero:plan:list')")
    @GetMapping("/listAll")
    public AjaxResult listAll(PlanInfo planInfo)
    {
        return AjaxResult.success(planInfoService.selectPlanInfoList(planInfo));
    }

    /**
     * 导出计划信息列表
     */
    @PreAuthorize("@ss.hasPermi('aero:plan:export')")
    @Log(title = "计划信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PlanInfo planInfo)
    {
        List<PlanInfo> list = planInfoService.selectPlanInfoList(planInfo);
        ExcelUtil<PlanInfo> util = new ExcelUtil<PlanInfo>(PlanInfo.class);
        util.exportExcel(response, list, "计划信息数据");
    }

    /**
     * 获取计划信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('aero:plan:query')")
    @GetMapping(value = "/{planId}")
    public AjaxResult getInfo(@PathVariable("planId") String planId)
    {
        return success(planInfoService.selectPlanInfoByPlanId(planId));
    }

    /**
     * 新增计划信息
     */
    @PreAuthorize("@ss.hasPermi('aero:plan:add')")
    @Log(title = "计划信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PlanInfo planInfo)
    {
        return toAjax(planInfoService.insertPlanInfo(planInfo));
    }

    /**
     * 修改计划信息
     */
    @PreAuthorize("@ss.hasPermi('aero:plan:edit')")
    @Log(title = "计划信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PlanInfo planInfo)
    {
        return toAjax(planInfoService.updatePlanInfo(planInfo));
    }

    /**
     * 删除计划信息
     */
    @PreAuthorize("@ss.hasPermi('aero:plan:remove')")
    @Log(title = "计划信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{planIds}")
    public AjaxResult remove(@PathVariable String[] planIds)
    {
        return toAjax(planInfoService.deletePlanInfoByPlanIds(planIds));
    }
}
